<?php

namespace iBrand\Component\Point;

use iBrand\Component\Point\Console\PointGoodsCommand;
use Illuminate\Support\ServiceProvider;
use Event;

class PointServiceProvider extends ServiceProvider
{

	/**
	 * bootstrap, add routes
	 */
	public function boot()
	{
		//publish a config file
		$this->publishes([
			__DIR__ . '/config.php' => config_path('point.php'),
		]);

		// merge configs
		$this->mergeConfigFrom(
			__DIR__ . '/config.php', 'point'
		);

		if ($this->app->runningInConsole()) {
			$this->registerMigrations();
		}

		$this->commands([
			PointGoodsCommand::class,
		]);

		Event::subscribe('iBrand\Component\Point\Listeners\PointEventListener');
	}

	/**
	 * register the service provider
	 */
	public function register()
	{

	}

	public function provides()
	{
		return ['Point'];
	}

	/**
	 * Register Passport's migration files.
	 *
	 * @return void
	 */
	protected function registerMigrations()
	{
		return $this->loadMigrationsFrom(__DIR__ . '/../migrations');
		/* $this->publishes([
			 __DIR__.'/../database/migrations' => database_path('migrations'),
		 ], 'user-migrations');*/
	}
}
